//
//  事件测试用例.swift
//  BDDExamplesSwift
//
//  Created by du on 2019/4/22.
//Copyright © 2019 huoshuguang. All rights reserved.
//

import Quick
import Nimble

@testable import BDDExamplesSwift
/// 创建替身MockEvent桩对象,实现Event代理属性,为行为测试提供数据输入
class MockEvent: NSObject,Event
{
    var name: String{
        return "nihao"
    }
    
    var startDate: NSDate{
        return NSDate.mt_date(fromYear: 2014, month: 8, day: 21) as NSDate
    }
    
    var endDate: NSDate{
        return self.startDate.mt_dateHours(after: 1) as NSDate
    }
    
}
class EventBDDUnit: QuickSpec {
    override func spec() {
        //我们的目标是测试 EventDescriptionFormatter 是否返回这样的格式化输出:
        //"My Event starts at Aug 21, 2014, 12:00 AM and ends at Aug 21, 2014, 1:00 AM."
        describe("测试Event格式化描述的行为:重点是能否正确获取字符串") {
            //在这里，我们不需要知道Event事件Formatter日期格式化器,仅专注于能否正确获取字符串的这个行为。
            var eventDescription:String?
            var mockEvent:MockEvent!
            var descriptionFormatter:EventDescriptionFormatter?
            afterEach {descriptionFormatter = nil}
            
            beforeEach {
                descriptionFormatter = EventDescriptionFormatter()
                // 创建替身MockEvent桩对象,实现Event代理属性,为行为测试提供数据输入
                mockEvent = MockEvent()
                //行为测试
                eventDescription = descriptionFormatter?.eventDescriptionFromEvent(event: mockEvent)
            }
            
            it("验证开始", closure: {
                //
                expect(eventDescription).to(equal("nihao starts at 8/21/14, 12:00:00 AM and ends at 8/21/14, 1:00:00 AM."))
            })
            
        }
    }
}
